home *** CD-ROM | disk | FTP | other *** search
- on loadMasterApp
- global gMasterAppObject
- if objectp(gMasterAppObject) then
- return 1
- end if
- if not objectp(factory("MasterApp")) then
- if not fileExists(the pathName & "MastrApp.dll") then
- alert("loadMasterApp(): can't locate MastrApp.dll")
- return 0
- end if
- openXLib("MastrApp.dll")
- end if
- if not objectp(factory("MasterApp")) then
- alert("loadMasterApp(): can't use MastrApp.dll")
- return 0
- end if
- if objectp(gMasterAppObject) then
- gMasterAppObject(mdispose)
- end if
- set gMasterAppObject to MasterApp(mnew)
- if not objectp(gMasterAppObject) then
- alert("loadMasterApp(): can't create MasterApp object")
- return 0
- end if
- return 1
- end
-
- on fileExists theFile
- set fioObj to FileIO(mnew, "read", theFile)
- if objectp(fioObj) then
- fioObj(mdispose)
- return 1
- end if
- return 0
- end
-
- on nicekillApp theModuleName, theWindowTypeName
- global gMasterAppObject
- if not loadMasterApp() then
- alert("niceKillApp(): no object")
- return 0
- end if
- set tl to gMasterAppObject(mGetTaskList)
- if tl = EMPTY then
- alert("niceKillApp(): empty task list")
- return 0
- end if
- pushDelim(",")
- set tllines to the number of lines in tl
- set targetTasks to 0
- repeat with i = 1 to tllines
- set theTaskLine to line i of tl
- if not (item 1 of theTaskLine = theModuleName) then
- next repeat
- end if
- set targetTasks to targetTasks + 1
- set theTask to integer(item 2 of theTaskLine)
- set wl to gMasterAppObject(mGetTaskWindowList, theTask)
- if wl = "EMTPY" then
- alert("niceKillApp(): target module with no windows")
- popDelim()
- return 0
- end if
- set wllines to the number of lines in wl
- set targetWindows to 0
- repeat with j = 1 to wllines
- set theWindowLine to line j of wl
- set wlItems to the number of items in theWindowLine
- if item wlItems of theWindowLine = theWindowTypeName then
- set targetWindows to targetWindows + 1
- set theWindow to integer(item wlItems - 3 of theWindowLine)
- gMasterAppObject(mWindowToFront, theWindow)
- gMasterAppObject(mCloseWindow, theWindow)
- set giveUpTicks to the ticks + (60 * 5)
- set itQuitItself to 0
- repeat while 1
- if gMasterAppObject(mWindowExists, theWindow) then
- gMasterAppObject(mFeedTimeSlice, theTask)
- else
- set itQuitItself to 1
- exit repeat
- end if
- if the ticks >= giveUpTicks then
- exit repeat
- end if
- end repeat
- if not itQuitItself then
- alert("niceKillApp(): target window didn't close in time")
- popDelim()
- return 0
- end if
- end if
- end repeat
- if targetWindows = 0 then
- alert("niceKillApp(): no target window was found")
- popDelim()
- return 0
- end if
- set giveUpTicks to the ticks + (60 * 5)
- set itQuitItself to 0
- repeat while 1
- if gMasterAppObject(mTaskIsRunning, theTask) then
- gMasterAppObject(mFeedTimeSlice, theTask)
- else
- set itQuitItself to 1
- exit repeat
- end if
- if the ticks >= giveUpTicks then
- exit repeat
- end if
- end repeat
- if not itQuitItself then
- alert("niceKillApp(): target task didn't close in time")
- popDelim()
- return 0
- end if
- end repeat
- if targetTasks = 0 then
- popDelim()
- return 0
- end if
- popDelim()
- return 1
- end
-
- on waitApp theModuleName, theWindowTypeName
- global gMasterAppObject
- if not loadMasterApp() then
- alert("waitApp(): no object")
- return 0
- end if
- set giveUpTicks to the ticks + (10 * 60)
- set foundIt to 0
- repeat while 1
- gMasterAppObject(mFeedGenericTimeSlice)
- if appRunning(theModuleName, theWindowTypeName) then
- set foundIt to 1
- exit repeat
- end if
- if the ticks > giveUpTicks then
- exit repeat
- end if
- end repeat
- return foundIt
- end
-
- on appRunning theModuleName, theWindowTypeName, tellWindowID
- global gMasterAppObject
- if not loadMasterApp() then
- alert("appRunning(): no object")
- return 0
- end if
- set tl to gMasterAppObject(mGetTaskList)
- if tl = EMPTY then
- alert("appRunning(): empty task list")
- return 0
- end if
- pushDelim(",")
- set tllines to the number of lines in tl
- repeat with i = 1 to tllines
- set theTaskLine to line i of tl
- if not (item 1 of theTaskLine = theModuleName) then
- next repeat
- end if
- set theTask to integer(item 2 of theTaskLine)
- set wl to gMasterAppObject(mGetTaskWindowList, theTask)
- if wl = "EMTPY" then
- next repeat
- end if
- set wllines to the number of lines in wl
- repeat with j = 1 to wllines
- set theWindowLine to line j of wl
- set wlItems to the number of items in theWindowLine
- if item wlItems of theWindowLine = theWindowTypeName then
- if not voidp(tellWindowID) then
- set valueToReturn to integer(item wlItems - 3 of theWindowLine)
- else
- set valueToReturn to 1
- end if
- popDelim()
- return valueToReturn
- end if
- end repeat
- end repeat
- popDelim()
- return 0
- end
-
- on getAppWin theModuleName, theWindowTypeName
- return appRunning(theModuleName, theWindowTypeName, "tell me more")
- end
-
- on pushDelim newItemDelim
- global gDelimList
- if not listp(gDelimList) then
- set gDelimList to []
- end if
- addAt(gDelimList, 1, the itemDelimiter)
- set the itemDelimiter to newItemDelim
- end
-
- on popDelim
- global gDelimList
- if not listp(gDelimList) then
- set gDelimList to []
- end if
- if count(gDelimList) = 0 then
- return
- end if
- set the itemDelimiter to getAt(gDelimList, 1)
- deleteAt(gDelimList, 1)
- end
-
- on rudeKillApp theModuleName
- global gMasterAppObject
- if not loadMasterApp() then
- alert("rudeKillApp(): no object")
- return 0
- end if
- set tl to gMasterAppObject(mGetTaskList)
- if tl = EMPTY then
- alert("rudeKillApp(): empty task list")
- return 0
- end if
- pushDelim(",")
- set tllines to the number of lines in tl
- set targetTasks to 0
- repeat with i = 1 to tllines
- set theTaskLine to line i of tl
- if not (item 1 of theTaskLine = theModuleName) then
- next repeat
- end if
- set targetTasks to targetTasks + 1
- set theTask to integer(item 2 of theTaskLine)
- gMasterAppObject(mRudeQuitTask, theTask, 0)
- set giveUpTicks to the ticks + (60 * 5)
- set itQuitItself to 0
- repeat while 1
- if gMasterAppObject(mTaskIsRunning, theTask) then
- gMasterAppObject(mFeedTimeSlice, theTask)
- else
- set itQuitItself to 1
- exit repeat
- end if
- if the ticks >= giveUpTicks then
- exit repeat
- end if
- end repeat
- if not itQuitItself then
- alert("rudeKillApp(): target task didn't close in time")
- popDelim()
- return 0
- end if
- end repeat
- if targetTasks = 0 then
- alert("rudeKillApp(): no target tasks were found")
- popDelim()
- return 0
- end if
- popDelim()
- return 1
- end
-
- on bringToFront
- global gMasterAppObject
- if not loadMasterApp() then
- alert("No object")
- return 0
- end if
- set tl to gMasterAppObject(mGetTaskList)
- if tl = EMPTY then
- return 0
- end if
- pushDelim(",")
- set tllines to the number of lines in tl
- set tTaskName to EMPTY
- set taskName to EMPTY
- repeat with i = 1 to tllines
- set theTaskLine to line i of tl
- set tTaskName to item 1 of theTaskLine
- if (tTaskName contains "setup") or (tTaskName contains "install") then
- set taskName to tTaskName
- set theTask to integer(item 2 of theTaskLine)
- exit repeat
- end if
- end repeat
- if taskName = EMPTY then
- return 0
- end if
- set wl to gMasterAppObject(mGetTaskWindowList, theTask)
- if wl = "EMTPY" then
- popDelim()
- return 0
- end if
- set wllines to the number of lines in wl
- set targetWindows to 0
- repeat with j = 1 to wllines
- set theWindowLine to line j of wl
- set wlItems to the number of items in theWindowLine
- if item 1 of theWindowLine = EMPTY then
- next repeat
- end if
- if item wlItems of theWindowLine <> EMPTY then
- set targetWindows to targetWindows + 1
- set theWindow to integer(item wlItems - 3 of theWindowLine)
- gMasterAppObject(mWindowToFront, theWindow)
- exit repeat
- end if
- end repeat
- return 1
- end
-
- on setpause
- global tickcounter
- set tickcounter to the ticks
- pause()
- end
-
- on doPause
- global tickcounter
- if the ticks > (tickcounter + 60) then
- continue()
- end if
- end
-